package com.mrwang.service;

import com.mrwang.mapper.CategoryMapper;
import com.mrwang.pojo.Category;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
@Service
public class CategoryService {
    @Resource
    CategoryMapper categoryMapper;

    public List<Category> categoryList(Long pid) {
        Category category = new Category();
        category.setParentId(pid);

        return categoryMapper.select(category);
    }


    public List<String> namesByIds(List<Long> cids) {
        List<String> list = new ArrayList<>();
        for (Long cid : cids) {
            Category category = categoryMapper.selectByPrimaryKey(cid);
            list.add(category.getName());
        }
        return list;
    }

    public List<String> queryNamesByIds(List<Long> cids) {
        List<String> list = new ArrayList<String>();
        for (Long cid : cids) {
            Category category = categoryMapper.selectByPrimaryKey(cid);
            list.add(category.getName());
        }
        return list;
    }
}
